Adjust ManagedType implementation and spec#15356
Conversation
|
Youssef do you still remember the details of why this change is needed here? And what is the impact of it on existing integrations. |
There was a problem hiding this comment.
Pull request overview
This PR updates the ManagedName utilities and the corresponding RFC to change how ManagedType is represented and resolved (moving away from an escaped identifier form toward using the raw CLR metadata type name).
Changes:
ManagedNameHelper.GetManagedName*now setsmanagedTypeNamefromType.FullNameand adjusts hierarchy extraction to use the type-builder string.ManagedNameHelper.GetMethodno longer unescapesmanagedTypeNamebefore callingAssembly.GetType.- RFC 0017 is updated to state that
ManagedTypemust not be escaped and adds a note in the Escaping section.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs | Changes ManagedType generation to use Type.FullName and updates GetMethod lookup behavior accordingly. |
| docs/RFCs/0017-Managed-TestCase-Properties.md | Updates the spec to state ManagedType is never escaped and amends the Escaping section. |
Comments suppressed due to low confidence (2)
docs/RFCs/0017-Managed-TestCase-Properties.md:145
- The RFC now states
ManagedTypemust not be escaped, but the Escaping section immediately below still describes escaping generically and the examples show an escaped/quoted “Parsed Type”. Please clarify/update this section (and/or the examples) so it’s unambiguous which fields can be escaped now (e.g., ManagedMethod only, not ManagedType).
This issue also appears on line 133 of the same file.
## Escaping
If an identifier does not conform to identifier naming rules, it gets escaped. An escaped identifier always start and end with a `'`. Note that `ManagedType` is never escaped.
```console
Type: CleanNamespaceName.SecondLevel.𝐌𝐲 𝘤𝘭𝘢𝘴𝘴 with 𝘢𝘯 𝒊𝒏𝒂𝒄𝒄𝒆𝒔𝒔𝒊𝒃𝒍𝒆 𝙣𝙖𝙢𝙚 🤷♀️
Method: int Sum(int x, int y)
Parsed Type: CleanNamespaceName.SecondLevel.'𝐌𝐲 𝘤𝘭𝘢𝘴𝘴 with 𝘢𝘯 𝒊𝒏𝒂𝒄𝒄𝒆𝒔𝒔𝒊𝒃𝒍𝒆 𝙣𝙖𝙢𝙚 🤷♀️'
Parsed Method: Sum(System.Int32,System.Int32)
Type: CleanNamespaceName.SecondLevel.Deeply wrong .namespace name.NamespaceA.Class1
Method: int Method with . in it(int x, int y)
Parsed Type: CleanNamespaceName.SecondLevel.'Deeply wrong '.'namespace name'.NamespaceA.Class1
Parsed Method: 'Method with . in it'(System.Int32,System.Int32)
docs/RFCs/0017-Managed-TestCase-Properties.md:135
- Grammar: “An escaped identifier always start and end…” should be “starts and ends…”.
## Escaping
If an identifier does not conform to identifier naming rules, it gets escaped. An escaped identifier always start and end with a `'`. Note that `ManagedType` is never escaped.
| public static MethodBase GetMethod(Assembly assembly, string managedTypeName, string managedMethodName) | ||
| { | ||
| var parsedManagedTypeName = ReflectionHelpers.ParseEscapedString(managedTypeName); | ||
| var type = assembly.GetType(parsedManagedTypeName, throwOnError: false, ignoreCase: false); | ||
| var type = assembly.GetType(managedTypeName, throwOnError: false, ignoreCase: false); | ||
|
|
||
| if (type == null) | ||
| { | ||
| string message = string.Format(CultureInfo.CurrentCulture, Resources.Resources.ErrorTypeNotFound, parsedManagedTypeName); | ||
| string message = string.Format(CultureInfo.CurrentCulture, Resources.Resources.ErrorTypeNotFound, managedTypeName); | ||
| throw new InvalidManagedNameException(message); | ||
| } |
|
@nohwnd I answered offline. It might be good if you work on summarizing and organizing the info and adding it publicly here. |
|
Yeah still need to put that in summary, and decide. |
Description
Please add a meaningful description for this change.
Ensure the PR has required unit tests.
Related issue
Kindly link any related issues. E.g. Fixes #xyz.